home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
UNIXTOOL
/
GNU
/
PERL
/
PERL5.ZIP
/
!Perl
/
Lib
/
Text
/
pm
/
abbrev
next >
Wrap
Text File
|
1994-10-18
|
593b
|
38 lines
package Text::Abbrev;
require 5.000;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(abbrev);
# Usage:
# &abbrev(*foo,LIST);
# ...
# $long = $foo{$short};
sub abbrev {
local(*domain) = shift;
@cmp = @_;
%domain = ();
foreach $name (@_) {
@extra = split(//,$name);
$abbrev = shift(@extra);
$len = 1;
foreach $cmp (@cmp) {
next if $cmp eq $name;
while (substr($cmp,0,$len) eq $abbrev) {
$abbrev .= shift(@extra);
++$len;
}
}
$domain{$abbrev} = $name;
while (@extra) {
$abbrev .= shift(@extra);
$domain{$abbrev} = $name;
}
}
}
1;